package com.example.raspberryPi_demo.service;

import com.example.raspberryPi_demo.entity.Equipment;
import com.example.raspberryPi_demo.mapper.EquipmentDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EquipmentService {

    @Autowired
    EquipmentDAO equipmentDAO;

    public Equipment findEquipmentByMacAddress(String macAddress) {
        return equipmentDAO.selectByPrimaryKey(macAddress);
    }

    public Equipment findEquipmentByName(String raspberrypiname) {
        return equipmentDAO.selectByName(raspberrypiname);
    }

    public List<Equipment> findEquipmentList() {
        return equipmentDAO.selectAll();
    }

    public int delete(String macAddress) {
        return equipmentDAO.deleteByPrimaryKey(macAddress);
    }

    public int update(String macAddress,Equipment equipment) {
        return equipmentDAO.updateByPrimaryKey(macAddress,equipment);
    }

    public int save(Equipment equipment) {
        return equipmentDAO.insert(equipment);
    }
}
